<?php

namespace Api\Model;


class MedicalCommentLikeModel extends BaseModel
{

    private static $instance;

    public static function singleton()
    {
        self::$instance === null and self::$instance = new self();
        return self::$instance;
    }

    public function getLikeArrByUserId($user_id, $comment_ids)
    {
        $comment_arr = [];
        $where['comment_id'] = ['IN', $comment_ids];
        $where['user_id'] = $user_id;
        $where['delete_time'] = 0;
        $rows = $this->where($where)->select();
        if ($rows) {
            foreach ($rows as $key => $val) {
                $comment_arr[] = $val['comment_id'];
            }
        }
        return $comment_arr;
    }

    //点赞之前是否已经点赞过了
    public function isCommentLikeBefore($comment_id, $user_id)
    {
        //之前是否点赞过
        $where['comment_id'] = $comment_id;
        $where['user_id'] = $user_id;
        $where['delete_time'] = 0;
        return $this->where($where)->find();
    }



}